#ifndef _APPS_BWM_DECORATIONS_CMANAGEDDECORATION_H_
#define _APPS_BWM_DECORATIONS_CMANAGEDDECORATION_H_

#include "auto.h"
#include "cpixmapdecoration.h"

#include <buola/gui/x11/cx11window.h>
#include <buola/utility/uevent.h>

namespace buola { namespace bwm {

class CManagedDecoration : public CPixmapDecoration
{
public:
    enum EButton
    {
        BUTTON_CLOSE,
        BUTTON_ICONIFY,
        BUTTON_MAXIMIZE,
        BUTTON_MENU,
        BUTTON_SHADE,
        BUTTON_STICKY,
        BUTTON_FULLSCREEN
    };

    CManagedDecoration(CClient *pClient);
    virtual ~CManagedDecoration();

//////////////// event handlers /////////////////
    virtual void OnClientActivated(bool);
    virtual void OnStateChanged(int,int);
    virtual void OnLabelChanged();
    virtual void OnDesktopSwitched();

protected:
    virtual void OnButtonDown(const CPoint_d&,gui::EMouseButton,int);
    virtual void OnButtonUp(const CPoint_d&,gui::EMouseButton,int);
    virtual void OnMouseMove(const CPoint_d&);
    virtual void OnMouseOut();

    void OnTimer();

/////////////////// helpers /////////////////
    virtual gui::EDragState GetDraggingZone(const CPoint_d&)=0;

public:
    UEvent<void()> eActivate;
    UEvent<void(CPoint_d)> eShowMenu;
    UEvent<void(EButton)> eButton;
    UEvent<void(gui::EDragState,CPoint_d,gui::EMouseButton)> eDrag;
    UEvent<void()> eDragCancel;

protected:
    bool mActive;

public:
//Dragging info
    int mLastDragZone;

public:
    friend class CRootWindow;
    friend class CEventManager;
};

/*namespace bwm*/ } /*namespace buola*/ }

#endif
